﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace middleware.utiles
{
    public static class Extension
    {
        public static List<string[]> ToStringArray(this IQueryable source)
        {

            Type type = source.ElementType;

            var properties = type.GetProperties();

            List<string> strs;

            List<string[]> list = new List<string[]>();

            foreach (var i in source)
            {

                strs = new List<string>();

                foreach (var p in properties)
                {

                    object value = p.GetValue(i, null);

                    strs.Add(value == null ? null : value.ToString());

                }

                list.Add(strs.ToArray());

            }
            return list;

        }
    }
}
